#include <stdio.h>
#include <stdlib.h>

/*
* I_2.c
*
*  Created on: April, 23, 2009
*      Author: yimingliu@fudan.edu.cn
*/

typedef struct aa
{
	int data;
	struct aa *next;
} NODE;

NODE *createlink(int n, int m)
{
	NODE *h=NULL,*p,*s;
	int i;
	p=(NODE*)malloc(sizeof(NODE));
	h=p;
	p->next=NULL;
	for(i=1;i<=n;i++)
	{
		s=(NODE*)malloc(sizeof(NODE));
		s->data=rand()%m;
		s->next=p->next;
		p->next=s;
		p=p->next;
	}
	return h;
}

void outlink(NODE *h)
{
	NODE *p;
	p=h->next;
	printf("\n\nTHE LIST: \n\n HEAD");
	while(p)
	{
		printf("->%d",p->data);
		p=p->next;
	}
	printf("\n");
}


void funI_2()
{
	NODE *head;
	head=createlink(8,22);
	outlink(head);
}